home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / AVIStripeSystem.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  3.1 KB  |  123 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #ifndef f_AVISTRIPESYSTEM_H
  19. #define f_AVISTRIPESYSTEM_H
  20.  
  21. #include <vfw.h>
  22.  
  23. #include "VirtualDub.h"
  24. #include "AVIReadHandler.h"
  25.  
  26. #pragma warning(push)
  27. #pragma warning(disable: 4200)    // nonstandard extension used
  28.  
  29. class AVIStripe {
  30. public:
  31.     enum {
  32.         FLAG_INDEX        = 1,
  33.         FLAG_VIDEO        = 2,
  34.         FLAG_AUDIO        = 4,
  35.  
  36.         MODE_MASTER        = FLAG_INDEX | FLAG_AUDIO,    // contains index + *all* audio
  37.         MODE_INDEX        = FLAG_INDEX,    // contains index only
  38.         MODE_VIDEO        = FLAG_VIDEO,    // contains video segments
  39.         MODE_AUDIO        = FLAG_AUDIO,    // contains audio segments
  40.         MODE_BOTH        = FLAG_VIDEO | FLAG_AUDIO,    // contains a/v segments
  41.     };
  42.  
  43.     long    lBufferSize, lChunkSize;
  44.     int        iNameLen;
  45.     char    cStripeMode;
  46.     signed char    scPriority;
  47.     char    szName[];
  48.  
  49.     void *operator new(size_t stSize, int iNameBytes);
  50.  
  51.     BOOL isIndex() { return !!(cStripeMode & FLAG_INDEX); }
  52.     BOOL isVideo() { return !!(cStripeMode & FLAG_VIDEO); }
  53.     BOOL isAudio() { return !!(cStripeMode & FLAG_AUDIO); }
  54. };
  55.  
  56. #pragma warning(pop)
  57.  
  58.  
  59. class AVIStripeSystem {
  60. private:
  61.     int nStripes;
  62.     AVIStripe **stripe;
  63.  
  64.     void _construct(int nStripes);
  65.     void _destruct();
  66. public:
  67.     AVIStripeSystem(int nStripes);
  68.     AVIStripeSystem(char *szFile);
  69.     ~AVIStripeSystem();
  70.  
  71.     void        Save(char *szFile);
  72.  
  73.     int            getStripeCount();
  74.     AVIStripe *    getStripeInfo(int nStripe);
  75. };
  76.  
  77. ////////////////////////////////////
  78.  
  79. class AVIStripeIndexEntry {
  80. public:
  81.     long    lSampleFirst;
  82.     long    lSampleCount;
  83.     long    lStripe;
  84.     long    lStripeSample;
  85. };
  86.  
  87. #define DEFINETEST(type) bool inline operator##type(long lSample, AVIStripeIndexEntry& asie)
  88.  
  89. DEFINETEST(< ) { return lSample <  asie.lSampleFirst; }
  90. DEFINETEST(>=) { return lSample >= asie.lSampleFirst; }
  91. DEFINETEST(> ) { return lSample >= asie.lSampleFirst + asie.lSampleCount; }
  92. DEFINETEST(<=) { return lSample <  asie.lSampleFirst + asie.lSampleCount; }
  93.  
  94. DEFINETEST(==)    {
  95.                     long t = lSample - asie.lSampleFirst;
  96.  
  97.                     return t>=0 && t<asie.lSampleCount;
  98.                 }
  99.  
  100. DEFINETEST(!=)    {
  101.                     long t = lSample - asie.lSampleFirst;
  102.  
  103.                     return t<0 || t>=asie.lSampleCount;
  104.                 }
  105.  
  106. #undef DEFINETEST
  107.  
  108. ////////////////////////////////////
  109.  
  110. class AVIStripeIndexLookup {
  111. private:
  112.     AVIStripeIndexEntry *index_table;
  113.     long index_table_size;
  114.  
  115. public:
  116.     AVIStripeIndexLookup(IAVIReadStream *pAVIIndex);
  117.     ~AVIStripeIndexLookup();
  118.  
  119.     AVIStripeIndexEntry *lookup(long sample);
  120. };
  121.  
  122. #endif
  123.